package com.dragon.modules.yuegou.enums.code;

import com.dragon.common.constant.enums.IBusinessCode;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 会员业务状态码
 * 
 * @author 刘武
 *
 */
public enum CouponCode implements IBusinessCode {

	/**
	 * 优惠券信息不能为空
	 */
	COUPONINFO(20001, "优惠券信息不能为空"),

	/**
	 * 可用停车场不能为空
	 */
	PARKLIST(20002, "可用停车场不能为空"),

	TICKET_EXCHANGE(20004, "小票兑换只能有一张券开启"),

	STATUS_WRONG(20005, "该状态不能审核"),

	TYPE_NOT_EXIST(20006, "停车劵类型不存在"),

	MERCHANT_USER_NOT_FIND(20007, "未找到商户用户信息"),

	MERCHANT_COUPON_APPLY_NOT_FIND(20008, "未找到停车券信息"),

	MERCHANT_COUPON_APPLY_EXPRIED(20009, "停车券已过期"),

	MERCHANT_COUPON_APPLY_ISNULL(20010, "停车券已发放完"),

	COUPON_ID_IS_NOT_NULL(20011, "福利ID不能为空"),

	NOT_IN_THE_TIME_FRAME(20012, "当前时间不在活动时间范围内无法开始！"),

	NO_SET_POINT_TEMPLATE(20013, "商圈未设置可积分兑换的停车券"),

	PRICE_ERROR(20014, "停车券价格必须大于0"),

	NOT_PAYED(20015, "停车券尚未支付"),

	LESS_THAN_BEGIN_TIME(20016, "尚未到开始发放时间"),

	CHECK_RD_IS_NOT_EMPTY(20017, "驳回审核备注不能为空"),

	NOT_CAN_EXCHANGE_PARK_COUPON(20018, "不能兑换停车券"),

	EXCHANGE_PARK_COUPON(20019, "已兑换，不能重复兑换"),
	
	TEMPLATE_NOT_RANDOM(20020, "随机券没有找到随机段"),
	
	MERCHANT_GROUP_EQUAL(20021, "商户平台平分数据输入错误"),
	
	LADDERS_TOTAL_TEMP_TOTAL_SUM(20022, "优惠券分布单阶梯数量总和超过优惠劵模板总量"),
	
	LADDERS_TOTAL_TEMP_TOTAL_AMOUNT(20023, "优惠券分布单阶梯总金额超过优惠劵模板总金额"),
	
	COUPON_AMOUNT_EXCEEDS_LIMIT(20024, "优惠券分布金额超过抵扣金额限制"),
	
	COUPON_AMOUNT_INTERSECTION(20025, "多个优惠券分布金额存在交集"),
	COUPON_TIME_IS_AFTER_EFFECTIVE_TIME(20026, "开始时间不能小于券的生效时间"),
	COUPON_TIME_IS_BEFORE_EXPIRATION_TIME(20027, "结束时间不能大于券的过期时间"),
	MEMBERSHIP_BENEFITS_HAVE_BEEN_SNAPPED_UP(20028, "抱歉来晚了，已抢光请下次早点来"),
	THE_COUPON_HAS_BEEN_MAXIMIZED(20029, "优惠券领取已达最大值"),

	OUTBOUND_GREATER_INVENTORY(20030, "出库数量大于库存数量"),
	
	SELECT_COUPON_NUM_ERROR(20031, "优惠券选择券错误"),
	
	SELECT_COUPON_OUT(20032, "选择优惠券优惠金额溢出了"),
	
	TEMPLATE_RANDOM_ZERO(20033, "随机券被别人抢走了，请重试"),
	NOT_OFF_THE_SHELVES(20034, "未下架，请先下架"),
	/**
	 * 状态码说明
	 */
	TODO(20000, "提示消息");

	private final Integer code;

	private final String message;

	private CouponCode(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	public Integer getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	/**
	 * 把code转化为ResponseCode枚举
	 * 
	 * @param code
	 *            代码
	 * @return
	 */
	public static CouponCode from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for ResponseCode
	 */
	private static final Map<Integer, CouponCode> CODE_MAP = Stream.of(CouponCode.values())
			.collect(Collectors.toMap(CouponCode::getCode, e -> e));

}
